
use crate::models::student::StudentModel;
use mysql::prelude::Queryable;
use rocket::serde::json::Json;
use rocket::Error;

pub struct StudentService;

impl StudentService {
    pub fn add(param: Json<StudentModel>) -> Result<bool, Error> {
        StudentModel::add(param)
    }

    pub fn query(param: Json<StudentModel>) -> Result<Vec<StudentModel>, Error> {
        let students = StudentModel::query(param);
        students
    }

    pub fn query_by_pk(id: i32) -> Result<Option<StudentModel>, Error> {
        let students = StudentModel::query_by_pk(id);
        students
    }

    pub fn update(param: Json<StudentModel>) -> Result<bool, Error> {
        StudentModel::update(param)
    }

    pub fn delete(id:i32) -> Result<bool, Error> {
        StudentModel::delete(id)
    }
}

